package com.halen.lock;

import java.util.Stack;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

public class AQSDemo {
    public static void main(String[] args) {
        ReentrantLock lock = new ReentrantLock();

        // 带入一个
        new Thread(() -> {
            lock.lock();
            try {
                System.out.println("---A thread come in");
                TimeUnit.MINUTES.sleep(20);
            } catch (Exception e) {
                e.printStackTrace();
            }finally {
                lock.unlock();
            }
        },"A").start();

        new Thread(() -> {
            lock.lock();
            try {
                System.out.println("---B thread come in");
            }finally {
                lock.unlock();
            }
        },"B").start();

        new Thread(() -> {
            lock.lock();
            try {
                System.out.println("---C thread come in");
            }finally {
                lock.unlock();
            }
        },"C").start();
    }
}
